// @ts-ignore
import {createRouter, RouteRecordRaw, createWebHashHistory,defineAsyncComponent } from "vue-router";

import activity from './activity/index.ts'

const routes: RouteRecordRaw[] = [
    {
        path: "/",
        name: "去测试",
        redirect: '/index',
    },
    {
        path: "/index",
        name: "等待中",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/index.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/activity",
        name: "赢现金活动",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/cashActivity.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/ranking",
        name: "排行榜",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/ranking.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/myIncome",
        name: "我的收益",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/myIncome.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/myShare",
        name: "分享",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/shareView.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/download",
        name: "下载",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/download/page1.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    },
    {
        path: "/invited",
        name: "邀请码",
        component: () =>
            import(/* webpackChunkName: "packinghouse" */(`../view/activity/invited.vue`)),
        meta: {
            keepAlive: false,
            rule: []
        }
    }

]
const router = createRouter({
    // 路由的history模式，共有三种模式，
    // createWebHistory、createWebHashHistory、createMemoryHistory
    history: createWebHashHistory(),
    //路由
    routes,
    // 是否严格匹配路由
    strict: true,
    // 路由跳转完成后，页面滚动行为
    scrollBehavior: () => ({left: 0, top: 0}),
});
// 路由跳转前验证
// @ts-ignore
router.beforeEach((to, from, next) => {
    next()
})
// 路由跳转后验证
// @ts-ignore
router.afterEach(() => {
// console.log('离开');
    //在这调用pinia
})
export default router;
